package datamining.core.main;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import datamining.code.dao.PublicacaoDAO;
import datamining.code.model.Publicacao;

public class RunnerMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		File output = new File("csvtables/afterprocessing/publicacoes.csv");
		FileWriter fileWriter;
		BufferedWriter bufferedWriter;
		try {
			fileWriter = new FileWriter(output);
			bufferedWriter = new BufferedWriter(fileWriter);
			PublicacaoDAO dao = new PublicacaoDAO();
			ArrayList<Object> dados = new ArrayList<Object>();
			dados = dao.retrieve();
			for (int i = 0; i < dados.size(); i++) {
				Publicacao pub = (Publicacao) dados.get(i);
				bufferedWriter.write(pub.getCodigo()+";"+pub.getNumChamada()+"\n");
			}
			bufferedWriter.flush();
			bufferedWriter.close();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
		
		

	}

}
